package com.finance.system.test;


import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class Cts {
    public static void main(String[] args) throws InterruptedException {
//        game();
//        walter();
        while(true){
            Thread.sleep(500);
            System.out.println(System.currentTimeMillis());
            System.out.println(Math.cos(100));
        }
    }


    public static void sortTest(List<Integer> data,int left,int right){
        if(right > left){
            int mid = left + (right - left)/2;
            sortTest(data,left,mid);
            sortTest(data,mid + 1,right);
            mergeChildTest(data,left,mid,mid + 1,right);
        }
    }

    private static void mergeChildTest(List<Integer> data, int aleft, int aright, int bleft,
                                       int bright) {
        ArrayList<Integer> tempList = new ArrayList<>();
        int aindex = aleft;
        int bindex = bleft;
        while(aindex <= aright || bindex <= bright){
            if(aindex > aright){
                //a数组取完了，b没有取完，直接从b中取剩余
                tempList.add(data.get(bindex++));
            }else if(bindex >bright){
                //b数组取完了，a没有取完，直接从a中取剩余
                tempList.add(data.get(aindex++));
            }else{
                Integer aNumber = data.get(aindex);
                Integer bNumber = data.get(bindex);
                if(aNumber < bNumber){
                    tempList.add(aNumber);
                    aindex++;
                }else{
                    tempList.add(bNumber);
                    bindex++;
                }
            }
        }


    }
    @Data
    static class Node<T>{
        private Node<T> next;
        private T data;
        private boolean isHead = false;
        private boolean isRear = false;

        private void put(Node node){
            Node last = findLast();
            last.next = node;

        }

        private Node findLast() {
            Node current = this;
            while(current.next != null){
                current = current.next;
            }
            return current;
        }
    }

    @Data
    static class Point{
        private Integer number;
        private boolean killed = false;

        public Point(Integer valueOf) {
            this.number = valueOf;
        }
    }

    public static void game(){
        int m = 3;
        int total = 10;
        Node<Point> head = new Node<>();
        head.isHead = true;
        head.data = new Point(1);
        for(int i = 2;i<=total;i++){
            Node<Point> pointNode = new Node<>();
            pointNode.data = new Point(i);
            head.put(pointNode);
        }
        int left = total;
        int countNUm = 0;
        Node<Point> tempNode = head;
        while(left >= m){
           if(tempNode.getData().isKilled()) {
               tempNode = tempNode.next;
               if(tempNode == null){
                   tempNode = head;
               }
           }else{
               countNUm++;
               if(countNUm == m){
                   tempNode.getData().setKilled(true);
                   left--;
                   countNUm = 0;
               }
               if(tempNode.next == null){
                   tempNode = head;
               }else{
                   tempNode = tempNode.next;
               }
           }
        }
        Node<Point> oneNode = head;
        while(oneNode != null){
            if(!oneNode.getData().isKilled()){
                System.out.print(oneNode.getData().number+" ");
            }
            oneNode = oneNode.next;
        }
    }

    public static void walter(){
        int h = 81;//有水的瓶子数
        int v = 0;//空瓶数
        int changeNum = 0;

        //drink
        v = v + h;
        h = h - h;
        while(v >= 3){
           changeNum++;
           h++;
           v-=3;
           v = v + h;
           h = h - h;
        }
        if(v == 2){
           changeNum++;
        }
        System.out.println(changeNum);
    }


}
